// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_PUR_QUOTE_ITEM
// * CreateDate    : 2011/8/16 10:16:41
// * Creater       : CodeSmith
// * LastChangeDate: 2011/8/16 10:16:41
// * LastChanger   : 2011/8/16 10:16:41
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Pur
{
/// <summary>
    /// PurQuoteItem
    /// </summary>
    public partial class PurQuoteItemBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objPurQuoteItemEntity">Entity</param>
        /// <returns>Entity</returns>
        public static PurQuoteItemEntity GetPurQuoteItem(PurQuoteItemEntity objPurQuoteItemEntity)
        {
            return DataAccess.SelectSingle<PurQuoteItemEntity>(objPurQuoteItemEntity);
        }
        public static PurQuoteItemEntity GetPurQuoteItemByID(string itemID)
        {
            if (string.IsNullOrEmpty(itemID))
            {
                return null;
            }
            PurQuoteItemEntity entity = new PurQuoteItemEntity();
            entity.QuoteItemId = itemID;
            return DataAccess.SelectSingle<PurQuoteItemEntity>(entity);
        }
        public static List<PurQuoteItemEntity> GetByQuoteOrderID(string quoteOrderID)
        {
            if (string.IsNullOrEmpty(quoteOrderID))
            {
                return null;
            }
            PurQuoteItemEntity entity = new PurQuoteItemEntity();
            entity.QuoteOrderId = quoteOrderID;
            return DataAccess.Select<PurQuoteItemEntity>(entity);
        }
        public static DataSet GetDataSetByQuoteOrderID(string quoteOrderID)
        {
            if (string.IsNullOrEmpty(quoteOrderID))
            {
                return null;
            }
            string sql = @"SELECT QI.*,P.*, CONVERT(DECIMAL(18,2),QI.QTY*QI.PRICE_NO_TAX) AS TOTAL_AMOUNT
                            FROM PUR_QUOTE_ITEM QI
                            INNER JOIN PUR_QUOTE_ORDER QO ON QO.QUOTE_ORDER_ID = QI.QUOTE_ORDER_ID
							LEFT JOIN PUR_PURCHASE_ORDER_ITEM POI ON POI.PURCHASE_ITEM_ID = QI.PURCHASE_ITEM_ID
                            LEFT JOIN MST_PRODUCT P ON P.PRODUCT_ID = POI.PRODUCT_ID
                            WHERE QI.QUOTE_ORDER_ID = '" + quoteOrderID + "'";
            return DataAccess.SelectDataSet(sql);
        }
        #endregion

        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objPurQuoteItemEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertPurQuoteItem(PurQuoteItemEntity objPurQuoteItemEntity)
        {
            return DataAccess.Insert(objPurQuoteItemEntity);
        }

        public static bool InsertPurQuoteItem(List<PurQuoteItemEntity> objPurQuoteItemEntityList)
        {
            return DataAccess.Insert(objPurQuoteItemEntityList);
        }
        #endregion

        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objPurQuoteItemEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdatePurQuoteItem(PurQuoteItemEntity objPurQuoteItemEntity)
        {
            return DataAccess.Update(objPurQuoteItemEntity);
        }

        public static bool UpdatePurQuoteItem(List<PurQuoteItemEntity> objPurQuoteItemEntityList)
        {
            return DataAccess.Update<PurQuoteItemEntity>(objPurQuoteItemEntityList);
        }
        #endregion

        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objPurQuoteItemEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeletePurQuoteItem(PurQuoteItemEntity objPurQuoteItemEntity)
        {
            return DataAccess.Delete(objPurQuoteItemEntity);
        }

        public static bool DeletePurQuoteItem(List<PurQuoteItemEntity> objPurQuoteItemEntityList)
        {
            return DataAccess.Delete<PurQuoteItemEntity>(objPurQuoteItemEntityList);
        }
        #endregion

        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetPurQuoteItemAll()
        {
            return DataAccess.SelectAllDataSet<PurQuoteItemEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<PurQuoteItemEntity> GetPurQuoteItemAllList()
        {
            return DataAccess.SelectAll<PurQuoteItemEntity>();
        }
        #endregion
	}
	
	
}	

